package cn.zktr.Personnel.model.service.tantiantian;

import java.util.List;
import java.util.Optional;

import javax.transaction.Transactional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.data.web.SpringDataWebProperties.Pageable;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSONArray;

import cn.zktr.Personnel.model.dao.tantiantian.SlyScsyDao;
import cn.zktr.Personnel.model.dao.tantiantian.SlyTaxDao;
import cn.zktr.Personnel.model.dao.zhouyongcong.PmsPotDao;
import cn.zktr.Personnel.model.mappers.tantiantian.ScsyMapper;
import cn.zktr.Personnel.model.pojos.PerPmsPot;
import cn.zktr.Personnel.model.pojos.PerSlyScsy;
import cn.zktr.Personnel.model.pojos.PerSlyTax;

@Service
@Transactional(rollbackOn=Exception.class)
public class SlyScsyService {
	/**
	 * 社保项目
	 */
	@Autowired
	private SlyScsyDao scsyDao;
	@Autowired 
	private ScsyMapper scsymer;
	
	/**
	 * 职位表
	 */
	@Autowired
	private PmsPotDao potDAo;
	/**
	 * 纳税
	 */
	@Autowired
	private SlyTaxDao taxDao;
	
	/**
	 * 查询所有社保项目
	 * @return 
	 */

	public JSONArray  selectScsyAll2() {
		return scsymer.select();
	}
	
	/**
	 * @param p
	 * @return新增一条数据，新增社保项目
	 */
	public void addScsy(PerSlyScsy p) {
		scsyDao.save(p);
	}
	
	/**
	 * @param scsyid
	 * @return根据id查询社保项目及纳税
	 */
	public JSONArray seleScsyId(Integer scsyid) {
		JSONArray sScsyId = scsymer.selectScsyId(scsyid);
		return sScsyId;
		
	}
	/**
	 * @param entity新增社保纳税
	 * @return 
	 */
	public void AddTAx(PerSlyTax entity) {
		entity.setTaxfs("无");
		taxDao.save(entity);
	}
	/**
	 * @param entity新增社保纳税
	 * @return 
	 */
	public void upScsy(Integer id) {
		Optional<PerSlyScsy> scsy = scsyDao.findById(id);
		PerSlyTax tax = scsymer.seleTaxlimt();
		System.err.println("实体类"+tax);
		scsy.get().setPerSlyTax(tax);
		scsyDao.save(scsy.get());
		
	}

	public JSONArray scsytable_name(String text) {
		
		return scsymer.scsytable_name("%"+text+"%");
	}
	
}
